/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.application.model;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author jhonny
 */
public class RetriveUtils {

    public RetriveUtils() {
    }
    private static void getProvincias(String dato,String regex,String out1,String out2){
        Pattern  pattern= Pattern.compile(regex, Pattern.CASE_INSENSITIVE|Pattern.MULTILINE|Pattern.DOTALL|Pattern.UNICODE_CASE|Pattern.UNIX_LINES);
        Matcher matcher =pattern.matcher(dato);
        while (matcher.find()) {            
            System.out.println(out1+matcher.group(1)+out2);
        }
    }
    private static void getProvinciasFromPais(String dato,String pais) {
        String regex = "showmatchedregions=true>(.*?)</option>";
        String out1 = "INSERT INTO provincia(pais_id,name) VALUES((select id from pais where name='"+pais+"'),'";
        String out2 = "');";
        getProvincias(dato, regex, out1, out2);
    }
    
    public static void getProvinciasArgentina(){
        String dato="<select style=display:undefined; name=sp.RegionBusqueda><option value=>Indistinto</option><option value=1 showmatchedregions=true>Capital Federal</option><option value=2 showmatchedregions=true>G.B.A. Zona Norte</option><option value=3 showmatchedregions=true>G.B.A. Zona Oeste</option><option value=4 showmatchedregions=true>G.B.A. Zona Sur</option><option value=5 showmatchedregions=true>Costa Atlantica</option><option value=6 showmatchedregions=true>Interior Buenos Aires</option><option value=8 showmatchedregions=true>Catamarca</option><option value=9 showmatchedregions=true>Chaco</option><option value=10 showmatchedregions=true>Chubut</option><option value=11 showmatchedregions=true>Cordoba</option><option value=12 showmatchedregions=true>Corrientes</option><option value=13 showmatchedregions=true>Entre Rios</option><option value=14 showmatchedregions=true>Formosa</option><option value=15 showmatchedregions=true>Jujuy</option><option value=16 showmatchedregions=true>La Pampa</option><option value=17 showmatchedregions=true>La Rioja</option><option value=18 showmatchedregions=true>Mendoza</option><option value=19 showmatchedregions=true>Misiones</option><option value=20 showmatchedregions=true>Neuquen</option><option value=22 showmatchedregions=true>Rio Negro</option><option value=23 showmatchedregions=true>Salta</option><option value=24 showmatchedregions=true>San Juan</option><option value=25 showmatchedregions=true>San Luis</option><option value=26 showmatchedregions=true>Santa Cruz</option><option value=27 showmatchedregions=true>Santa Fe</option><option value=28 showmatchedregions=true>Santiago Del Estero</option><option value=29 showmatchedregions=true>Tierra Del Fuego</option><option value=30 showmatchedregions=true>Tucuman</option></select>";
        getProvinciasFromPais(dato,"Argentina");
    }
    public static void getProvinciasUruguay() {
        String dato = "<select style=display:undefined; name=sp.RegionBusqueda><option value=>Indistinto</option><option value=200 showmatchedregions=true>Montevideo</option><option value=201 showmatchedregions=true>Maldonado</option><option value=202 showmatchedregions=true>Artigas</option><option value=203 showmatchedregions=true>Canelones</option><option value=204 showmatchedregions=true>Cerro Largo</option><option value=205 showmatchedregions=true>Colonia</option><option value=206 showmatchedregions=true>Durazno</option><option value=207 showmatchedregions=true>Flores</option><option value=208 showmatchedregions=true>Florida</option><option value=209 showmatchedregions=true>Lavalleja</option><option value=210 showmatchedregions=true>Paysandu</option><option value=211 showmatchedregions=true>Rio Negro</option><option value=212 showmatchedregions=true>Rivera</option><option value=213 showmatchedregions=true>Rocha</option><option value=214 showmatchedregions=true>Salto</option><option value=215 showmatchedregions=true>San Jose</option><option value=216 showmatchedregions=true>Soriano</option><option value=217 showmatchedregions=true>Tacuarembo</option><option value=218 showmatchedregions=true>Treinta y Tres</option></select>";
        getProvinciasFromPais(dato,"Uruguay");
    }
    public static void getProvinciasBolivia() {
        String dato = "";
        getProvinciasFromPais(dato,"Bolivia");
    }
    public static void getProvinciasBrasil() {
        String dato = "";
        getProvinciasFromPais(dato,"Brasil");
    }
    public static void getProvinciasChile() {
        String dato = "";
        getProvinciasFromPais(dato,"Chile");
    }
    public static void getProvinciasParaguay() {
        String dato = "";
        getProvinciasFromPais(dato,"Paraguay");
    }
    public static void getProvinciasOtrosPaises() {
        String dato = "";
        getProvinciasFromPais(dato,"Otros países");
    }

    public static void getBarriosProvinciaCABA() {
        String dato = "<div class=ContMiddle id=ContMiddle><div class=Columna><dl><dt><input type=checkbox value=1 class=Barrios><label>Abasto</label></dt></dl><dl><dt><input type=checkbox value=42 class=Barrios><label>Agronomia</label></dt></dl><dl><dt><input type=checkbox value=2 class=Barrios><label>Almagro</label></dt><dd class=clearfix><input type=checkbox value=1 class=SubBarrios><label>Almagro Norte</label></dd><dd class=clearfix><input type=checkbox value=2 class=SubBarrios><label>Almagro Sur</label></dd></dl><dl><dt><input type=checkbox value=44 class=Barrios><label>Balvanera</label></dt></dl><dl><dt><input type=checkbox value=3 class=Barrios><label>Barracas</label></dt></dl><dl><dt><input type=checkbox value=4 class=Barrios><label>Barrio Norte</label></dt><dd class=clearfix><input type=checkbox value=3 class=SubBarrios><label>P.Las Heras</label></dd><dd class=clearfix><input type=checkbox value=4 class=SubBarrios><label>Plaza S.Martin</label></dd><dd class=clearfix><input type=checkbox value=5 class=SubBarrios><label>Recoleta</label></dd></dl><dl><dt><input type=checkbox value=5 class=Barrios><label>Belgrano</label></dt><dd class=clearfix><input type=checkbox value=6 class=SubBarrios><label>Belgrano Barrancas</label></dd><dd class=clearfix><input type=checkbox value=8 class=SubBarrios><label>Belgrano C</label></dd><dd class=clearfix><input type=checkbox value=9 class=SubBarrios><label>Belgrano Chico</label></dd><dd class=clearfix><input type=checkbox value=7 class=SubBarrios><label>Belgrano R</label></dd><dd class=clearfix><input type=checkbox value=10 class=SubBarrios><label>Las Cañitas</label></dd></dl><dl><dt><input type=checkbox value=6 class=Barrios><label>Boca</label></dt></dl><dl><dt><input type=checkbox value=7 class=Barrios><label>Boedo</label></dt></dl><dl><dt><input type=checkbox value=8 class=Barrios><label>Caballito</label></dt><dd class=clearfix><input type=checkbox value=11 class=SubBarrios><label>Caballito Norte</label></dd><dd class=clearfix><input type=checkbox value=12 class=SubBarrios><label>Caballito Sur</label></dd><dd class=clearfix><input type=checkbox value=13 class=SubBarrios><label>Cid Campeador</label></dd><dd class=clearfix><input type=checkbox value=16 class=SubBarrios><label>P.Junta</label></dd><dd class=clearfix><input type=checkbox value=14 class=SubBarrios><label>P.Lezica</label></dd><dd class=clearfix><input type=checkbox value=15 class=SubBarrios><label>P.Rivadavia</label></dd></dl><dl><dt><input type=checkbox value=9 class=Barrios><label>Centro</label></dt><dd class=clearfix><input type=checkbox value=17 class=SubBarrios><label>Catalinas</label></dd><dd class=clearfix><input type=checkbox value=18 class=SubBarrios><label>Microcentro</label></dd><dd class=clearfix><input type=checkbox value=19 class=SubBarrios><label>Monserrat</label></dd><dd class=clearfix><input type=checkbox value=23 class=SubBarrios><label>Puerto Madero</label></dd><dd class=clearfix><input type=checkbox value=20 class=SubBarrios><label>Retiro</label></dd><dd class=clearfix><input type=checkbox value=21 class=SubBarrios><label>S.Nicolas</label></dd><dd class=clearfix><input type=checkbox value=22 class=SubBarrios><label>Tribunales</label></dd></dl></div><div class=Columna><dl><dt><input type=checkbox value=10 class=Barrios><label>Chacarita</label></dt></dl><dl><dt><input type=checkbox value=41 class=Barrios><label>Coghlan</label></dt></dl><dl><dt><input type=checkbox value=11 class=Barrios><label>Colegiales</label></dt></dl><dl><dt><input type=checkbox value=12 class=Barrios><label>Congreso</label></dt></dl><dl><dt><input type=checkbox value=13 class=Barrios><label>Constitucion</label></dt></dl><dl><dt><input type=checkbox value=14 class=Barrios><label>Flores</label></dt><dd class=clearfix><input type=checkbox value=24 class=SubBarrios><label>Flores Norte</label></dd><dd class=clearfix><input type=checkbox value=25 class=SubBarrios><label>Flores Sur</label></dd></dl><dl><dt><input type=checkbox value=15 class=Barrios><label>Floresta</label></dt><dd class=clearfix><input type=checkbox value=26 class=SubBarrios><label>Floresta Norte</label></dd><dd class=clearfix><input type=checkbox value=27 class=SubBarrios><label>Floresta Sur</label></dd><dd class=clearfix><input type=checkbox value=28 class=SubBarrios><label>Monte Castro</label></dd><dd class=clearfix><input type=checkbox value=29 class=SubBarrios><label>P.Avellaneda</label></dd></dl><dl><dt><input type=checkbox value=16 class=Barrios><label>Liniers</label></dt><dd class=clearfix><input type=checkbox value=30 class=SubBarrios><label>B.Naon</label></dd></dl><dl><dt><input type=checkbox value=17 class=Barrios><label>Mataderos</label></dt></dl><dl><dt><input type=checkbox value=18 class=Barrios><label>Nuñez</label></dt><dd class=clearfix><input type=checkbox value=32 class=SubBarrios><label>L.De Nuñez</label></dd><dd class=clearfix><input type=checkbox value=31 class=SubBarrios><label>River</label></dd></dl><dl><dt><input type=checkbox value=19 class=Barrios><label>Once</label></dt></dl><dl><dt><input type=checkbox value=21 class=Barrios><label>P.Centenario</label></dt></dl><dl><dt><input type=checkbox value=22 class=Barrios><label>P.Chacabuco</label></dt></dl><dl><dt><input type=checkbox value=23 class=Barrios><label>P.Patricios</label></dt></dl><dl><dt><input type=checkbox value=20 class=Barrios><label>Palermo</label></dt><dd class=clearfix><input type=checkbox value=33 class=SubBarrios><label>Botanico</label></dd><dd class=clearfix><input type=checkbox value=34 class=SubBarrios><label>Palermo Chico</label></dd><dd class=clearfix><input type=checkbox value=36 class=SubBarrios><label>Palermo Hollywood</label></dd><dd class=clearfix><input type=checkbox value=38 class=SubBarrios><label>Palermo Nuevo</label></dd><dd class=clearfix><input type=checkbox value=37 class=SubBarrios><label>Palermo Soho</label></dd><dd class=clearfix><input type=checkbox value=35 class=SubBarrios><label>Palermo Viejo</label></dd></dl></div><div class=Columna><dl><dt><input type=checkbox value=24 class=Barrios><label>Paternal</label></dt></dl><dl><dt><input type=checkbox value=43 class=Barrios><label>Pompeya</label></dt></dl><dl><dt><input type=checkbox value=26 class=Barrios><label>S.Cristobal</label></dt></dl><dl><dt><input type=checkbox value=27 class=Barrios><label>S.Telmo</label></dt></dl><dl><dt><input type=checkbox value=25 class=Barrios><label>Saavedra</label></dt></dl><dl><dt><input type=checkbox value=29 class=Barrios><label>V.Crespo</label></dt></dl><dl><dt><input type=checkbox value=30 class=Barrios><label>V.Devoto</label></dt><dd class=clearfix><input type=checkbox value=39 class=SubBarrios><label>B.San Pedro</label></dd></dl><dl><dt><input type=checkbox value=31 class=Barrios><label>V.Gral.Mitre</label></dt></dl><dl><dt><input type=checkbox value=32 class=Barrios><label>V.Lugano</label></dt></dl><dl><dt><input type=checkbox value=33 class=Barrios><label>V.Luro</label></dt></dl><dl><dt><input type=checkbox value=40 class=Barrios><label>V.Ortuzar</label></dt></dl><dl><dt><input type=checkbox value=34 class=Barrios><label>V.Parque</label></dt><dd class=clearfix><input type=checkbox value=40 class=SubBarrios><label>B.Santa Rita</label></dd></dl><dl><dt><input type=checkbox value=35 class=Barrios><label>V.Pueyrredon</label></dt></dl><dl><dt><input type=checkbox value=36 class=Barrios><label>V.Real</label></dt></dl><dl><dt><input type=checkbox value=37 class=Barrios><label>V.Riachuelo</label></dt></dl><dl><dt><input type=checkbox value=38 class=Barrios><label>V.Soldati</label></dt></dl><dl><dt><input type=checkbox value=39 class=Barrios><label>V.Urquiza</label></dt><dd class=clearfix><input type=checkbox value=41 class=SubBarrios><label>B.P.Saavedra</label></dd><dd class=clearfix><input type=checkbox value=42 class=SubBarrios><label>P.Chass</label></dd><dd class=clearfix><input type=checkbox value=43 class=SubBarrios><label>Urquiza R</label></dd></dl><dl><dt><input type=checkbox value=45 class=Barrios><label>Velez Sarsfield</label></dt></dl><dl><dt><input type=checkbox value=28 class=Barrios><label>Versailles</label></dt></dl></div></div>";
        String regex ="class=Barrios><label>(.*?)</label>(.*?)<dl><dt><input";
        Pattern  pattern= Pattern.compile(regex, Pattern.CASE_INSENSITIVE|Pattern.MULTILINE|Pattern.DOTALL|Pattern.UNICODE_CASE|Pattern.UNIX_LINES);
        Matcher matcher =pattern.matcher(dato);
        while (matcher.find()) {
            System.out.println(matcher.group(1));
            getSubBarriosProvincia(matcher.group(2));
        }
        
    }
    public static void getPartidoGBAZonaNorte() {
        String dato = "<select style=display:block; name=sp.Partido><option value=>Indistinto</option><option value=19>Campana</option><option value=39>Escobar</option><option value=41>Exaltacion De La Cruz</option><option value=58>General San Martin</option><option value=65>Jose Clemente Paz</option><option value=80>Malvinas Argentinas</option><option value=97>Pilar</option><option value=115>San Fernando</option><option value=116>San Isidro</option><option value=117>San Miguel</option><option value=124>Tigre</option><option value=131>Vicente Lopez</option><option value=134>Zarate</option></select>";
        String regex = "value=[0123456789]{1,}>(.*?)</option>";
        getPartidosProvincia(dato,regex);
    }
    public static void getPartidoGBAZonaOeste() {
        String dato = "<select style=display:block; name=sp.Partido><option value=>Indistinto</option><option value=20>Cañuelas</option><option value=57>General Rodriguez</option><option value=63>Hurlingham</option><option value=64>Ituzaingo</option><option value=67>La Matanza</option><option value=77>Lujan</option><option value=82>Marcos Paz</option><option value=84>Merlo</option><option value=87>Moreno</option><option value=88>Moron</option><option value=129>Tres De Febrero</option></select>";
        String regex = "value=[0123456789]{1,}>(.*?)</option>";
        getPartidosProvincia(dato,regex);
    }    
    public static void getPartidoGBAZonaSur() {
        String dato = "<select style=display:block; name=sp.Partido><option value=>Indistinto</option><option value=6>Almirante Brown</option><option value=8>Avellaneda</option><option value=15>Berazategui</option><option value=16>Berisso</option><option value=38>Ensenada</option><option value=40>Esteban Echeverria</option><option value=42>Ezeiza</option><option value=43>Florencio Varela</option><option value=68>La Plata</option><option value=69>Lanus</option><option value=76>Lomas De Zamora</option><option value=99>Presidente Peron</option><option value=102>Quilmes</option><option value=120>San Vicente</option></select>";
        String regex = "value=[0123456789]{1,}>(.*?)</option>";
        getPartidosProvincia(dato,regex);
    }
    public static void getPartidoInteriorBuenosAires() {
        String dato = "<select style=display:block; name=sp.Partido><option value=>Indistinto</option><option value=1>25 De Mayo</option><option value=2>9 De Julio</option><option value=3>Adolfo Alsina</option><option value=4>Adolfo Gonzales Chaves</option><option value=5>Alberti</option><option value=7>Arrecifes</option><option value=9>Ayacucho</option><option value=10>Azul</option><option value=11>Bahia Blanca</option><option value=12>Balcarce</option><option value=13>Baradero</option><option value=14>Benito Juarez</option><option value=17>Bolivar</option><option value=18>Bragado</option><option value=21>Capitan Sarmiento</option><option value=22>Carlos Casares</option><option value=23>Carlos Tejedor</option><option value=24>Carmen De Areco</option><option value=25>Castelli</option><option value=26>Chacabuco</option><option value=27>Chascomus</option><option value=28>Chivilcoy</option><option value=29>Colon</option><option value=30>Coronel Brandsen</option><option value=31>Coronel Dorrego</option><option value=32>Coronel Pringles</option><option value=33>Coronel Rosales</option><option value=34>Coronel Suarez</option><option value=35>Daireaux</option><option value=36>De La Costa</option><option value=37>Dolores</option><option value=44>Florentino Ameghino</option><option value=45>General Alvarado</option><option value=46>General Alvear</option><option value=47>General Arenales</option><option value=48>General Belgrano</option><option value=49>General Guido</option><option value=50>General Lamadrid</option><option value=51>General Las Heras</option><option value=52>General Lavalle</option><option value=53>General Madariaga</option><option value=54>General Paz</option><option value=55>General Pinto</option><option value=56>General Pueyrredon</option><option value=59>General Viamonte</option><option value=60>General Villegas</option><option value=61>Guamini</option><option value=62>Hipolito Yrigoyen</option><option value=66>Junin</option><option value=70>Laprida</option><option value=71>Las Flores</option><option value=72>Leandro N Alem</option><option value=73>Lincoln</option><option value=74>Loberia</option><option value=75>Lobos</option><option value=78>Magdalena</option><option value=79>Maipu</option><option value=81>Mar Chiquita</option><option value=83>Mercedes</option><option value=85>Monte</option><option value=86>Monte Hermoso</option><option value=89>Navarro</option><option value=90>Necochea</option><option value=91>Olavarria</option><option value=92>Patagones</option><option value=93>Pehuajo</option><option value=94>Pellegrini</option><option value=95>Pergamino</option><option value=96>Pila</option><option value=98>Pinamar</option><option value=100>Puan</option><option value=101>Punta Indio</option><option value=103>Ramallo</option><option value=104>Rauch</option><option value=105>Rivadavia</option><option value=106>Rojas</option><option value=107>Roque Perez</option><option value=108>Saavedra</option><option value=109>Saladillo</option><option value=110>Salliquelo</option><option value=111>Salto</option><option value=112>San Andres De Giles</option><option value=113>San Antonio De Areco</option><option value=114>San Cayetano</option><option value=118>San Nicolas</option><option value=119>San Pedro</option><option value=121>Suipacha</option><option value=122>Tandil</option><option value=123>Tapalque</option><option value=125>Tordillo</option><option value=126>Tornquist</option><option value=127>Trenque Lauquen</option><option value=128>Tres Arroyos</option><option value=130>Tres Lomas</option><option value=132>Villa Gesell</option><option value=133>Villarino</option></select>";
        String regex = "value=[0123456789]{1,}>(.*?)</option>";
        getPartidosProvincia(dato,regex);
    }
    public static void getPartidoCatamarca() {
        String dato = "";
        String regex = "value=[0123456789]{1,}>(.*?)</option>";
        getPartidosProvincia(dato,regex);
    }
    
    private static void getPartidosProvincia(String dato,String regex) {
    	Pattern  pattern= Pattern.compile(regex, Pattern.CASE_INSENSITIVE|Pattern.MULTILINE|Pattern.DOTALL|Pattern.UNICODE_CASE|Pattern.UNIX_LINES);
        Matcher matcher =pattern.matcher(dato);
        while (matcher.find()) {
            System.out.println(matcher.group(1));
        }
    }
    
    public static void getLocalidadCostaAtlantica() {
        String dato = "<div class=ContMiddle id=ContMiddle><div class=Columna><dl><dt><input type=checkbox value=647 class=Localidades><label>Aguas Verdes</label></dt></dl><dl><dt><input type=checkbox value=218 class=Localidades><label>Bahia Blanca</label></dt></dl><dl><dt><input type=checkbox value=1248 class=Localidades><label>Balneario Mar Chiquita</label></dt></dl><dl><dt><input type=checkbox value=1310 class=Localidades><label>Balneario Oriente</label></dt></dl><dl><dt><input type=checkbox value=1311 class=Localidades><label>Balneario Sauce Grande</label></dt></dl><dl><dt><input type=checkbox value=905 class=Localidades><label>Barrio Chapadmalal</label></dt></dl><dl><dt><input type=checkbox value=1591 class=Localidades><label>Carilo</label></dt></dl><dl><dt><input type=checkbox value=648 class=Localidades><label>Costa Azul</label></dt></dl><dl><dt><input type=checkbox value=649 class=Localidades><label>Costa Del Este</label></dt></dl><dl><dt><input type=checkbox value=650 class=Localidades><label>La Lucila Del Mar</label></dt></dl><dl><dt><input type=checkbox value=651 class=Localidades><label>Las Toninas</label></dt></dl><dl><dt><input type=checkbox value=2038 class=Localidades><label>Mar Azul</label></dt><dd class=clearfix><input type=checkbox value=4481 class=Barrios><label>Las Gaviotas</label></dd></dl><dl><dt><input type=checkbox value=652 class=Localidades><label>Mar De Ajo</label></dt></dl><dl><dt><input type=checkbox value=2039 class=Localidades><label>Mar De Las Pampas</label></dt></dl><dl><dt><input type=checkbox value=920 class=Localidades><label>Mar Del Plata</label></dt><dd class=clearfix><input type=checkbox value=65 class=Barrios><label>Antartida Argentina</label></dd><dd class=clearfix><input type=checkbox value=10195 class=Barrios><label>Arenas del Sur</label></dd><dd class=clearfix><input type=checkbox value=62 class=Barrios><label>B.2 De Abril</label></dd><dd class=clearfix><input type=checkbox value=58 class=Barrios><label>B.Ameghino</label></dd><dd class=clearfix><input type=checkbox value=68 class=Barrios><label>B.Belgrano</label></dd><dd class=clearfix><input type=checkbox value=69 class=Barrios><label>B.F.U.Camet</label></dd><dd class=clearfix><input type=checkbox value=54 class=Barrios><label>B.Hipodromo</label></dd><dd class=clearfix><input type=checkbox value=59 class=Barrios><label>B.Las Americas</label></dd><dd class=clearfix><input type=checkbox value=63 class=Barrios><label>B.Las Margaritas</label></dd><dd class=clearfix><input type=checkbox value=52 class=Barrios><label>B.Libertad</label></dd><dd class=clearfix><input type=checkbox value=57 class=Barrios><label>B.Los Pinares</label></dd><dd class=clearfix><input type=checkbox value=4399 class=Barrios><label>Barrio 180</label></dd><dd class=clearfix><input type=checkbox value=81 class=Barrios><label>Bosque Alegre</label></dd><dd class=clearfix><input type=checkbox value=46 class=Barrios><label>C.Corrientes</label></dd><dd class=clearfix><input type=checkbox value=104 class=Barrios><label>Caisamar</label></dd><dd class=clearfix><input type=checkbox value=47 class=Barrios><label>Camet</label></dd><dd class=clearfix><input type=checkbox value=48 class=Barrios><label>Centro</label></dd><dd class=clearfix><input type=checkbox value=4400 class=Barrios><label>Cerenil</label></dd><dd class=clearfix><input type=checkbox value=4393 class=Barrios><label>Cerrito</label></dd><dd class=clearfix><input type=checkbox value=105 class=Barrios><label>Chauvin</label></dd><dd class=clearfix><input type=checkbox value=49 class=Barrios><label>Constitucion</label></dd><dd class=clearfix><input type=checkbox value=70 class=Barrios><label>Divino Rostro</label></dd><dd class=clearfix><input type=checkbox value=4391 class=Barrios><label>Dorrego</label></dd><dd class=clearfix><input type=checkbox value=72 class=Barrios><label>El Gaucho</label></dd><dd class=clearfix><input type=checkbox value=50 class=Barrios><label>El Marquesado</label></dd><dd class=clearfix><input type=checkbox value=94 class=Barrios><label>El Martillo</label></dd><dd class=clearfix><input type=checkbox value=73 class=Barrios><label>El Monolito</label></dd><dd class=clearfix><input type=checkbox value=4398 class=Barrios><label>El Progreso</label></dd><dd class=clearfix><input type=checkbox value=95 class=Barrios><label>Estacion Ferrocarril</label></dd><dd class=clearfix><input type=checkbox value=4394 class=Barrios><label>Estrada</label></dd><dd class=clearfix><input type=checkbox value=51 class=Barrios><label>Faro</label></dd><dd class=clearfix><input type=checkbox value=4409 class=Barrios><label>Fortunato de La Plaz</label></dd><dd class=clearfix><input type=checkbox value=4404 class=Barrios><label>Gral. San Martin</label></dd><dd class=clearfix><input type=checkbox value=96 class=Barrios><label>Grosellar</label></dd><dd class=clearfix><input type=checkbox value=4403 class=Barrios><label>Jorge Newbery</label></dd><dd class=clearfix><input type=checkbox value=4397 class=Barrios><label>Juramento</label></dd><dd class=clearfix><input type=checkbox value=10206 class=Barrios><label>La Armonia</label></dd><dd class=clearfix><input type=checkbox value=106 class=Barrios><label>La Bristol</label></dd><dd class=clearfix><input type=checkbox value=107 class=Barrios><label>La Caleta</label></dd><dd class=clearfix><input type=checkbox value=97 class=Barrios><label>La Florida</label></dd><dd class=clearfix><input type=checkbox value=108 class=Barrios><label>La Perla Norte</label></dd><dd class=clearfix><input type=checkbox value=98 class=Barrios><label>La Perla Sur</label></dd><dd class=clearfix><input type=checkbox value=71 class=Barrios><label>Las Avenidas</label></dd><dd class=clearfix><input type=checkbox value=4396 class=Barrios><label>Las Colinas P.Ramos</label></dd><dd class=clearfix><input type=checkbox value=4402 class=Barrios><label>Las Dalias</label></dd><dd class=clearfix><input type=checkbox value=66 class=Barrios><label>Los Acantilados</label></dd><dd class=clearfix><input type=checkbox value=4392 class=Barrios><label>Los Andes</label></dd><dd class=clearfix><input type=checkbox value=99 class=Barrios><label>Los Pinares</label></dd><dd class=clearfix><input type=checkbox value=4405 class=Barrios><label>Los Tilos</label></dd><dd class=clearfix><input type=checkbox value=109 class=Barrios><label>Los Troncos</label></dd><dd class=clearfix><input type=checkbox value=4395 class=Barrios><label>Lourdes</label></dd><dd class=clearfix><input type=checkbox value=78 class=Barrios><label>Materno Infantil</label></dd><dd class=clearfix><input type=checkbox value=88 class=Barrios><label>Microcentro</label></dd><dd class=clearfix><input type=checkbox value=4401 class=Barrios><label>Montemar</label></dd><dd class=clearfix><input type=checkbox value=79 class=Barrios><label>Mundialista</label></dd><dd class=clearfix><input type=checkbox value=100 class=Barrios><label>P.Grande</label></dd><dd class=clearfix><input type=checkbox value=110 class=Barrios><label>P.Luro</label></dd><dd class=clearfix><input type=checkbox value=102 class=Barrios><label>P.Mogotes</label></dd><dd class=clearfix><input type=checkbox value=111 class=Barrios><label>P.Ramos Bosque</label></dd><dd class=clearfix><input type=checkbox value=60 class=Barrios><label>Parque Independencia</label></dd><dd class=clearfix><input type=checkbox value=4406 class=Barrios><label>Parque Palermo</label></dd><dd class=clearfix><input type=checkbox value=61 class=Barrios><label>Parque Peña</label></dd><dd class=clearfix><input type=checkbox value=89 class=Barrios><label>Pinos De Anchorena</label></dd><dd class=clearfix><input type=checkbox value=90 class=Barrios><label>Playa Chica</label></dd><dd class=clearfix><input type=checkbox value=53 class=Barrios><label>Playa Serena</label></dd><dd class=clearfix><input type=checkbox value=67 class=Barrios><label>Playas Del Sur</label></dd><dd class=clearfix><input type=checkbox value=91 class=Barrios><label>Plaza Colon</label></dd><dd class=clearfix><input type=checkbox value=92 class=Barrios><label>Plaza Mitre</label></dd><dd class=clearfix><input type=checkbox value=64 class=Barrios><label>Plaza Rocha</label></dd><dd class=clearfix><input type=checkbox value=93 class=Barrios><label>Pompeya</label></dd><dd class=clearfix><input type=checkbox value=4389 class=Barrios><label>Primera Junta</label></dd><dd class=clearfix><input type=checkbox value=101 class=Barrios><label>Puerto</label></dd><dd class=clearfix><input type=checkbox value=4390 class=Barrios><label>Punta Iglesia</label></dd><dd class=clearfix><input type=checkbox value=4408 class=Barrios><label>Punta Piedras</label></dd><dd class=clearfix><input type=checkbox value=4414 class=Barrios><label>Rumenco</label></dd><dd class=clearfix><input type=checkbox value=55 class=Barrios><label>Ruta 226</label></dd><dd class=clearfix><input type=checkbox value=56 class=Barrios><label>Ruta 88</label></dd><dd class=clearfix><input type=checkbox value=82 class=Barrios><label>San Carlos</label></dd><dd class=clearfix><input type=checkbox value=4387 class=Barrios><label>San Cayetano</label></dd><dd class=clearfix><input type=checkbox value=83 class=Barrios><label>San Jorge</label></dd><dd class=clearfix><input type=checkbox value=74 class=Barrios><label>San Jose</label></dd><dd class=clearfix><input type=checkbox value=84 class=Barrios><label>San Juan</label></dd><dd class=clearfix><input type=checkbox value=75 class=Barrios><label>Santa Cecilia</label></dd><dd class=clearfix><input type=checkbox value=4407 class=Barrios><label>Santa Celina</label></dd><dd class=clearfix><input type=checkbox value=85 class=Barrios><label>Santa Monica</label></dd><dd class=clearfix><input type=checkbox value=4388 class=Barrios><label>Sarmiento</label></dd><dd class=clearfix><input type=checkbox value=86 class=Barrios><label>Sierra De Los Padres</label></dd><dd class=clearfix><input type=checkbox value=87 class=Barrios><label>Stella Maris</label></dd><dd class=clearfix><input type=checkbox value=76 class=Barrios><label>Terminal</label></dd><dd class=clearfix><input type=checkbox value=103 class=Barrios><label>Torreon</label></dd><dd class=clearfix><input type=checkbox value=77 class=Barrios><label>Varese</label></dd><dd class=clearfix><input type=checkbox value=80 class=Barrios><label>Villa Primera</label></dd></dl></div><div class=Columna><dl><dt><input type=checkbox value=653 class=Localidades><label>Mar Del Tuyu</label></dt></dl><dl><dt><input type=checkbox value=767 class=Localidades><label>Miramar</label></dt></dl><dl><dt><input type=checkbox value=1312 class=Localidades><label>Monte Hermoso</label></dt></dl><dl><dt><input type=checkbox value=1592 class=Localidades><label>Montecarlo</label></dt></dl><dl><dt><input type=checkbox value=1369 class=Localidades><label>Necochea</label></dt></dl><dl><dt><input type=checkbox value=654 class=Localidades><label>Nueva Atlantis</label></dt></dl><dl><dt><input type=checkbox value=1593 class=Localidades><label>Ostende</label></dt></dl></div><div class=Columna><dl><dt><input type=checkbox value=1595 class=Localidades><label>Pinamar</label></dt></dl><dl><dt><input type=checkbox value=657 class=Localidades><label>San Bernardo Del Tuyu</label></dt></dl><dl><dt><input type=checkbox value=658 class=Localidades><label>San Clemente Del Tuyu</label></dt></dl><dl><dt><input type=checkbox value=1267 class=Localidades><label>Santa Clara Del Mar</label></dt></dl><dl><dt><input type=checkbox value=659 class=Localidades><label>Santa Teresita</label></dt></dl><dl><dt><input type=checkbox value=1596 class=Localidades><label>Valeria Del Mar</label></dt></dl><dl><dt><input type=checkbox value=2040 class=Localidades><label>Villa Gesell</label></dt></dl><dl><dt></div></div>";
        String regex = "class=Localidades><label>(.*?)</label></dt>.*?(class=Barrios>)?(.*?)<dl><dt>";
        Pattern  pattern= Pattern.compile(regex, Pattern.CASE_INSENSITIVE|Pattern.MULTILINE|Pattern.DOTALL|Pattern.UNICODE_CASE|Pattern.UNIX_LINES);
        Matcher matcher =pattern.matcher(dato);
        while (matcher.find()) {
            System.out.println(matcher.group(1));
            getBarriosLocalidad(matcher.group(3));
        }
    }
    private static void getBarriosLocalidad(String dato) {
    	String regex="class=Barrios><label>(.*?)</label></dd>";
    	Pattern  pattern= Pattern.compile(regex, Pattern.CASE_INSENSITIVE|Pattern.MULTILINE|Pattern.DOTALL|Pattern.UNICODE_CASE|Pattern.UNIX_LINES);
        Matcher matcher =pattern.matcher(dato);
        while (matcher.find()) {
            System.out.println(matcher.group(1));
            
        }
    }
    
    
    
    private static void getSubBarriosProvincia(String dato) {
    	String regex="class=SubBarrios><label>(.*?)</label>";
    	Pattern  pattern= Pattern.compile(regex, Pattern.CASE_INSENSITIVE|Pattern.MULTILINE|Pattern.DOTALL|Pattern.UNICODE_CASE|Pattern.UNIX_LINES);
        Matcher matcher =pattern.matcher(dato);
        while (matcher.find()) {
            System.out.println(matcher.group(1));
            
        }
    }
}
